package com.guit.hrms.controller;

import com.guit.hrms.po.utilsPO.PageBean;
import com.guit.hrms.po.utilsPO.Result;
import com.guit.hrms.service.StatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Validated
@CrossOrigin
@RestController
@RequestMapping("/api/statistics")
public class StatisticsController {
    @Autowired
    private StatisticsService statisticsService;

    /**
     * 统计招聘计划转化率
     * @param page
     * @param pageSize
     * @param planId
     * @param planType
     * @return
     */
    @GetMapping("/recruit/announcements")
    public Result countRecruitment(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer pageSize,
                                   Integer planId, Integer planType) {

        PageBean pageBean = statisticsService.countRecruitment(page, pageSize, planId, planType);
        if (pageBean.getTotal() == 0L) {
            return Result.error("没有数据");
        }

        return Result.success(pageBean);
    }

    /**
     * 统计面试通过率
     * @param page
     * @param pageSize
     * @param planId
     * @param planType
     * @param interviewId
     * @param deptId
     * @param positionNumber
     * @return
     */
    @GetMapping("/interview")
    public Result statisticalInterviewPassRate(@RequestParam(defaultValue = "1") Integer page,
                            @RequestParam(defaultValue = "10") Integer pageSize,
                            Integer planId, Integer planType ,Integer interviewId,String deptId,String positionNumber) {
        PageBean pageBean = statisticsService.statisticalInterviewPassRate(page, pageSize, planId, planType, interviewId, deptId, positionNumber);

        return Result.success(pageBean);
    }
}
